package com.yanqu.road.logic.helper;

import com.yanqu.road.entity.activity.ActivityConditionInfo;
import com.yanqu.road.entity.activity.ActivityConfig;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.*;
import com.yanqu.road.logic.sort.CrossFellingTreesLevelRankSort;
import com.yanqu.road.logic.sort.CrossSeacraftPirateRiotChapterRankSort;
import com.yanqu.road.logic.sort.CrossUserRankSortWithParam;
import com.yanqu.road.logic.sort.FellingTreesLevelRankSort;
import com.yanqu.road.logic.sort.SeacraftPirateRiotChapterRankSort;
import com.yanqu.road.logic.sort.UserRankSortWithParam;
import com.yanqu.road.logic.sort.*;
import com.yanqu.road.logic.sort.yrank.DaoMuPvpPersonRankSort;
import com.yanqu.road.utils.date.DateHelper;

import java.util.Comparator;
import java.util.List;
import java.util.Map;

public class ActivityHelper {

    public static final int COMMON_ACTIVITY_CONDITION_TYPE_USER = 1;
    public static final int COMMON_ACTIVITY_CONDITION_TYPE_UNION = 2;
    public static final int COMMON_ACTIVITY_CONDITION_TYPE_CROSS = 3;

    public static int getCrossRankConditionType(int activityType, int childType){
        if(eActivityType.CrossRankActivity.getValue() == activityType) {//跨服活动
            if (eCrossRankActivityType.CrossEarnSpeedRiseRank.getValue() == childType) {
                return eGamePlayerEventType.EarnSpeedRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossIntimacyRiseRank.getValue() == childType) {
                return eGamePlayerEventType.IntimacyRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossAbilityRiseRank.getValue() == childType) {
                return eGamePlayerEventType.AbilityRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossQualificationRiseRank.getValue() == childType) {
                return eGamePlayerEventType.QualificationRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossBanquetPopularityRiseRank.getValue() == childType) {
                return eGamePlayerEventType.BanquetPopularityRank.getValue();
            } else if (eCrossRankActivityType.CrossChildEarnSpeedRiseRank.getValue() == childType) {
                return eGamePlayerEventType.ChildEarnSpeedRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossGlamourRiseRank.getValue() == childType) {
                return eGamePlayerEventType.GlamourRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossClinicScoreRiseRank.getValue() == childType) {
                return eGamePlayerEventType.ClinicScoreRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossManorOutPutCountRank.getValue() == childType) {
                return eGamePlayerEventType.ManorOutPutCountRank.getValue();
            } else if (eCrossRankActivityType.CrossBeautyEscortAddExpRank.getValue() == childType) {
                return eGamePlayerEventType.BeautyEscortAddExpRank.getValue();
            } else if (eCrossRankActivityType.CrossWineShopPleasureRiseRank.getValue() == childType) {
                return eGamePlayerEventType.WineShopPleasureRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossMonopolyMarketResGrabRank.getValue() == childType) {
                return eGamePlayerEventType.MonopolyMarketRank.getValue();
            } else if (eCrossRankActivityType.CrossFishPondScoreRiseRank.getValue() == childType) {
                return eGamePlayerEventType.FishPondRankActivityRank.getValue();
            } else if (eCrossRankActivityType.CrossGrandChildEarnSpeedRiseRank.getValue() == childType) {
                return eGamePlayerEventType.CrossGrandChildEarnSpeedRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossOnlyEscortAddExpRank.getValue() == childType) {
                return eGamePlayerEventType.OnlyEscortAddExpRank.getValue();
            } else if (eCrossRankActivityType.CrossDrugStoreTongBiRiseRank.getValue() == childType){
                return eGamePlayerEventType.DrugStoreTongBiCrossUserRank.getValue();
            } else if (eCrossRankActivityType.CrossWineryAromaRiseRank.getValue() == childType) {
                return eGamePlayerEventType.WineryAromaRankActivityCrossUserRank.getValue();
            } else {
                return 0;
            }
        }else if(eActivityType.CrossUnionActivity.getValue() == activityType){//跨服商会争霸
            if(eCrossUnionRankActivityType.unionEarnSpeedRiseRank.getIntValue() == childType){
                return eGamePlayerEventType.UnionEarnSpeedRiseRank.getValue();
            }else if(eCrossUnionRankActivityType.unionIntimacyRiseRank.getIntValue() == childType){
                return eGamePlayerEventType.UnionIntimacyRiseRank.getValue();
            }else if(eCrossUnionRankActivityType.unionExpRiseRank.getIntValue() == childType){
                return eGamePlayerEventType.UnionExpRiseRank.getValue();
            }
        }else if (eActivityType.CrossHuaShiGangActivity.getValue() == activityType) {
            return eGamePlayerEventType.HuaShiGangScoreRank.getValue();
        }else if (eActivityType.CrossDunHuangShiKuActivity.getValue() == activityType) {
            // 敦煌石窟个人积分排行
            return eGamePlayerEventType.DunHuangShiKuScoreCrossRank.getValue();
        }else if (eActivityType.CookingBoyActivity.getValue() == activityType){
            if(childType == 1){//小当家1阶段
                return eGamePlayerEventType.CookBoy1IntegralServerCrossRank.getValue();
            }
        } else if (eActivityType.MusicRoomRank.getValue() == activityType) {
            return eGamePlayerEventType.MusicRoomScoreRank.getValue();
        }else if (eActivityType.BowArtActivity.getValue() == activityType) {
            return eGamePlayerEventType.BowArtActivityScoreCrossRank.getValue();
        }
        return 0;
    }

    public static boolean isCrossRankConditionType(int conditionType){
        return eGamePlayerEventType.EarnSpeedRiseRank.getValue() == conditionType || eGamePlayerEventType.IntimacyRiseRank.getValue() == conditionType
                || eGamePlayerEventType.AbilityRiseRank.getValue() == conditionType || eGamePlayerEventType.QualificationRiseRank.getValue() == conditionType
                || eGamePlayerEventType.TradeWarScoreRiseRank.getValue() == conditionType || eGamePlayerEventType.GlamourRiseRank.getValue() == conditionType
                || eGamePlayerEventType.ChildEarnSpeedRiseRank.getValue() == conditionType || eGamePlayerEventType.BanquetPopularityRank.getValue() == conditionType
                || eGamePlayerEventType.HuaShiGangScoreRank.getValue() == conditionType || eGamePlayerEventType.ClinicScoreRiseRank.getValue() == conditionType
                || eGamePlayerEventType.DunHuangShiKuScoreCrossRank.getValue() == conditionType || eGamePlayerEventType.BeautyEscortAddExpRank.getValue() == conditionType
                || eGamePlayerEventType.ManorOutPutCountRank.getValue() == conditionType
                || eGamePlayerEventType.WineShopPleasureRiseRank.getValue() == conditionType
                || eGamePlayerEventType.MonopolyMarketRank.getValue() == conditionType
                || eGamePlayerEventType.FishPondRankActivityRank.getValue() == conditionType
                || eGamePlayerEventType.CrossGrandChildEarnSpeedRiseRank.getValue() == conditionType
                || eGamePlayerEventType.OnlyEscortAddExpRank.getValue() == conditionType
                || eGamePlayerEventType.DrugStoreTongBiCrossUserRank.getValue() == conditionType
                || eGamePlayerEventType.WineryAromaRankActivityCrossUserRank.getValue() == conditionType
                || eGamePlayerEventType.GreatTradePrestigeCrossRank.getValue() == conditionType
                || eGamePlayerEventType.GreatTradeAssetCrossRank.getValue() == conditionType
                || eGamePlayerEventType.CatActivityPassRank.getValue() == conditionType
                || eGamePlayerEventType.CatActivityDamageRank.getValue() == conditionType
                || eGamePlayerEventType.CarpTripCellNumCrossRank.getValue() == conditionType
                || eGamePlayerEventType.MusicRoomScoreRank.getValue() == conditionType
                ;
    }

    /**
     * 区服榜单类型
     * newRank获取区服榜单
     *
     * @param conditionType
     * @return
     */
    public static boolean isCrossServerRankConditionType(int conditionType) {
        if (conditionType == eGamePlayerEventType.ServerMusicRoomScoreRank.getValue()) {
            return true;
        }
        if (conditionType == eGamePlayerEventType.BowArtActivityServerScoreRank.getValue()) {
            return true;
        }
        return false;
    }

    /**
     * 继承BaseNewRankActivityCondition的榜单,是否需要更新区服榜
     * @param conditionType
     * @return
     */
    public static boolean isNewRankNeedServerRank(int conditionType) {
        if (conditionType == eGamePlayerEventType.MusicRoomScoreRank.getValue()) {
            return true;
        }
        if (conditionType == eGamePlayerEventType.BowArtActivityScoreCrossRank.getValue()) {
            return true;
        }
        return false;
    }

    /**
     * 判断榜单类型是否0值上榜
     *
     * @param conditionType
     * @return
     */
    public static boolean isConditionRankNeedZero(int conditionType) {
        if (conditionType == eGamePlayerEventType.EveFeastUserRank.getValue()) {
            return false;
        } else if (conditionType == eGamePlayerEventType.DaoMuPvePersonRank.getValue()) {
            return false;
        } else if (conditionType == eGamePlayerEventType.DaoMuPvpPersonRank.getValue()) {
            return false;
        } else if (conditionType == eGamePlayerEventType.GuaGiftsGuaRank.getValue()) {
            return false;
        } else if (conditionType == eGamePlayerEventType.GuaGiftsNobleRank.getValue()) {
            return false;
        } else if (conditionType == eGamePlayerEventType.MusicRoomScoreRank.getValue()) {
            return false;
        } else if (conditionType == eGamePlayerEventType.ZhenHuanFirstProcessRank.getValue()) {
            return false;
        }  else if (conditionType == eGamePlayerEventType.ZhenHuanSecondProcessRank.getValue()) {
            return false;
        } else if (conditionType == eGamePlayerEventType.ZhenHuanThirdProcessRank.getValue()) {
            return false;
        } else if (conditionType == eGamePlayerEventType.HarpsScoreRank.getValue()) {
            return false;
        } else if (conditionType == eGamePlayerEventType.OnlyEscortAddExpRank.getValue()) {
            return false;
        }
        return true;
    }

    public static int getCrossServerRankConditionType(int activityType, int childType) {
        if (eActivityType.CrossRankActivity.getValue() == activityType) {
            if (eCrossRankActivityType.CrossEarnSpeedRiseRank.getValue() == childType) {
                return eGamePlayerEventType.ServerEarnSpeedRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossIntimacyRiseRank.getValue() == childType) {
                return eGamePlayerEventType.ServerIntimacyRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossAbilityRiseRank.getValue() == childType) {
                return eGamePlayerEventType.ServerAbilityRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossQualificationRiseRank.getValue() == childType) {
                return eGamePlayerEventType.ServerQualificationRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossBanquetPopularityRiseRank.getValue() == childType) {
                return eGamePlayerEventType.ServerBanquetPopularityRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossChildEarnSpeedRiseRank.getValue() == childType) {
                return eGamePlayerEventType.ServerChildEarnSpeedRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossGlamourRiseRank.getValue() == childType) {
                return eGamePlayerEventType.ServerGlamourRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossClinicScoreRiseRank.getValue() == childType) {
                return eGamePlayerEventType.ServerClinicScoreRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossManorOutPutCountRank.getValue() == childType) {
                return eGamePlayerEventType.ServerManorOutPutCountRank.getValue();
            } else if (eCrossRankActivityType.CrossBeautyEscortAddExpRank.getValue() == childType) {
                return eGamePlayerEventType.ServerBeautyEscortAddExpRank.getValue();
            } else if (eCrossRankActivityType.CrossWineShopPleasureRiseRank.getValue() == childType) {
                return eGamePlayerEventType.ServerWineShopPleasureRank.getValue();
            } else if (eCrossRankActivityType.CrossMonopolyMarketResGrabRank.getValue() == childType) {
                return eGamePlayerEventType.MonopolyMarketServerRank.getValue();
            } else if (eCrossRankActivityType.CrossFishPondScoreRiseRank.getValue() == childType) {
                return eGamePlayerEventType.FishPondRankActivityServerRank.getValue();
            } else if (eCrossRankActivityType.CrossGrandChildEarnSpeedRiseRank.getValue() == childType) {
                return eGamePlayerEventType.ServerGrandChildEarnSpeedRiseRank.getValue();
            } else if (eCrossRankActivityType.CrossOnlyEscortAddExpRank.getValue() == childType) {
                return eGamePlayerEventType.ServerOnlyEscortAddExpRank.getValue();
            } else if (eCrossRankActivityType.CrossDrugStoreTongBiRiseRank.getValue() == childType) {
                return eGamePlayerEventType.DrugStoreTongBiCrossServerRank.getValue();
            } else if (eCrossRankActivityType.CrossWineryAromaRiseRank.getValue() == childType) {
                return eGamePlayerEventType.WineryAromaRankActivityCrossServerRank.getValue();
            } else {
                return 0;
            }
        } else if (eActivityType.MusicRoomRank.getValue() == activityType) {
            // 妙音坊
            return eGamePlayerEventType.ServerMusicRoomScoreRank.getValue();
        } else if (eActivityType.BowArtActivity.getValue() == activityType) {
            return eGamePlayerEventType.BowArtActivityServerScoreRank.getValue();
        } else {
            return 0;
        }
    }

    public static int getMaxRank(List<ActivityConditionInfo> activityConditionInfoList) {
        if(null == activityConditionInfoList){
            return 0;
        }
        int maxRank = 0;
        for (ActivityConditionInfo activityConditionInfo : activityConditionInfoList) {
            int param2 = activityConditionInfo.getParamList().get(1).intValue();
            if (param2 > maxRank) {
                maxRank = param2;
            }
        }
        return maxRank;
    }

    public static int getMaxRankByConditionType(int conditionType, List<ActivityConditionInfo> activityConditionInfoList) {
        if(null == activityConditionInfoList){
            return 0;
        }
        int maxRank = 0;
        for (ActivityConditionInfo activityConditionInfo : activityConditionInfoList) {
            if(activityConditionInfo.getType() == conditionType) {
                int param2 = activityConditionInfo.getParamList().get(1).intValue();
                if (param2 > maxRank) {
                    maxRank = param2;
                }
            }
        }
        return maxRank;
    }

    public static boolean activityInShowTime(ActivityInfo activityInfo){
        if(null == activityInfo){
            return false;
        }
        long nowTime = System.currentTimeMillis() / 1000;
        return nowTime >= activityInfo.getBeginShowTime() && nowTime < activityInfo.getEndShowTime();
    }

    /**
     * 活动展示期内 + 3 天内
     * @param activityInfo
     * @return
     */
    public static boolean activityInShowTimeAddThreeDay(ActivityInfo activityInfo){
        if(null == activityInfo){
            return false;
        }
        long endShowTimeAddThreeDay = activityInfo.getEndShowTime() + 3 * DateHelper.DAY_SECONDS;
        long nowTime = System.currentTimeMillis() / 1000;
        return nowTime >= activityInfo.getBeginShowTime() && nowTime < endShowTimeAddThreeDay;
    }


    /**
     * 活动进行时间
     */
    public static boolean activityInTime(ActivityInfo activityInfo) {
        if(null == activityInfo){
            return false;
        }
        long now = System.currentTimeMillis() / 1000;
        return activityInfo.getBeginTime() <= now && activityInfo.getEndTime() > now;
    }

    /**
     * 条件类型是否跨服
     * @param conditionType
     * @return
     */
    public static boolean conditionTypeIsCrossRank(int conditionType){
        if(eGamePlayerEventType.PageantSingleScoreRank.getValue() == conditionType){
            return false;
        }else if(eGamePlayerEventType.PageantTotalScoreRank.getValue() == conditionType){
            return false;
        }else if(eGamePlayerEventType.PageantSingleScoreCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.PageantTotalScoreCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.HolidayActivityScoreRank.getValue() == conditionType){
            return false;
        }else if(eGamePlayerEventType.HolidayActivityScoreCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.ThrowingPotScoreRank.getValue() == conditionType){
            return false;
        }else if(eGamePlayerEventType.ThrowingPotScoreCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.YearMasterScoreCrossRank.getValue() == conditionType){
            return true;
        } else if (eGamePlayerEventType.PplScoreCrossRank.getValue() == conditionType) {
            return true;
        }else if(eGamePlayerEventType.TreasureActivityScoreCrossRank.getValue() == conditionType){
            return true;
        } else if (eGamePlayerEventType.JianChuangHuaScoreCrossRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.DrawPicturesIntegralCrossRank.getValue() == conditionType) {
            return true;
        }else if(eGamePlayerEventType.DaFuWengScoreRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.DaFuWengUnionScoreRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.DaFuWengDamageRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.DaFuWengUnionDamageRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.TangHuLuScoreRank.getValue() == conditionType){
            return false;
        }else if(eGamePlayerEventType.TangHuLuScoreCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.ShuiHuScoreRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.BowArtActivityScoreCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.BowArtActivityScoreRank.getValue() == conditionType){
            return false;
        }else if(eGamePlayerEventType.BowArtActivityUnionScoreRank.getValue() == conditionType){
            return false;
        }else if(eGamePlayerEventType.BowArtActivityUnionScoreCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.BowArtActivityServerScoreRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.GhostScoreRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.GhostUnionScoreRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.PawnshopScoreCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.SuoYaoScoreRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.BusyFarmingScoreCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.HangHaiUnionMoneyRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.HangHaiMoneyRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.GuGuoXunBaoClueNumCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.DrinkActivityScoreRank.getValue() == conditionType){
            return false;
        }else if(eGamePlayerEventType.DrinkActivityCrossScoreRank.getValue() == conditionType){
            return true;
        } else if(eGamePlayerEventType.DragonBoatRaceActivityScoreCrossRank.getValue() == conditionType) {
            return true;
        } else if(eGamePlayerEventType.DragonBoatRaceActivityUnionScoreCrossRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.XiaYueCrossScoreRank.getValue() == conditionType) {
            return true;
        }else if(eGamePlayerEventType.DunHuangShiKuScoreCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.DunHuangShiKuTeamScoreCrossRank.getValue() == conditionType) {
            return true;
        }else if(eGamePlayerEventType.CelebrationActivityScoreCrossRank.getValue() == conditionType) {
            return true;
        }else if(eGamePlayerEventType.LanRuoSiActivityCrossScoreRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.GourdChildDamageCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.GourdChildPassProgressCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.GourdPlantScoreCrossRank.getValue() == conditionType){
            return true;
        }else if (eGamePlayerEventType.WinterLoveRank.getValue()==conditionType){
            return true;
        } else if (eGamePlayerEventType.YingXinCrossScoreRank.getValue() == conditionType) {
            return true;
        }else if(eGamePlayerEventType.HellActivityScoreCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.DouLuoDaLuPhaseTwoUserScoreCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.DouLuoDaLuPhaseOneUserScoreCrossRank.getValue() == conditionType){
            return true;
        }else if (eGamePlayerEventType.XiaowuRecallRank.getValue()==conditionType){
            return true;
        }else if(eGamePlayerEventType.DouLuoShrekActivityScoreCrossRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.DouLuoShrekActivityScoreCrossRank2.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.ShuiHuYeZiCardScoreRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.ShuiHuYeZiCardTotalCardLevelRank.getValue() == conditionType){
            return true;
        }else if(eGamePlayerEventType.SpringDinnerScoreCrossRank.getValue() == conditionType){
            return true;
        } else if(eGamePlayerEventType.SpringDinnerMaxScoreCrossRank.getValue() == conditionType){
            return true;
        } else if (eGamePlayerEventType.SeacraftPirateRiotScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.SeacraftPirateRiotUnionScoreRank.getValue() == conditionType) {
            return true;
        }else if(eGamePlayerEventType.SeacraftSouthSeaUserScoreRank.getValue() == conditionType){
            return true;
        } else if (eGamePlayerEventType.ToyHouseCrossScoreRank.getValue() == conditionType) {
            return true;
        } else if(eGamePlayerEventType.ChineseChessTopScoreRank.getValue() == conditionType){
            return true;
        }else if (eGamePlayerEventType.ShuShanMaxMagicUserRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.TongBingUserZhanGongRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.ZhouNianTurntableScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.ClimbTowerCellNumCrossRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.WineryAromaRankActivityCrossUserRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.GreatTradeAssetCrossRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.GreatTradePrestigeCrossRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.OperaMaskSumScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.PastureMaxScoreRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.RankUnionWarUnionScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.FellingTreesLevelRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.TombUserRank.getValue() == conditionType){
            return true;
        } else if (eGamePlayerEventType.TombUnionRank.getValue() == conditionType){
            return true;
        }else if (eGamePlayerEventType.TwinsUserScoreRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.TwinsUnionScoreRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.TwinsPassDamageRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.CatActivityPassRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.WorldCupScoreRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.CatActivityDamageRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.PeakStrongHoldUserDamageRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.PeakStrongHoldUnionIntegralRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.LionDanceScoreRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.CarpTripCellNumCrossRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.FireWorkScoreRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.FanXiuSpringScoreRank.getValue() == conditionType){
            return true;
        } else if (eGamePlayerEventType.XiuXianPersonalScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.XiuXianSectScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.XiuXianXianLiRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.FeastXianLiRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.FlowerCardCrossScoreRank.getValue() == conditionType){
            return true;
        } else if (eGamePlayerEventType.JieShiJiaoZiRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.PeakSeacraftUserScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.PeakSeacraftUnionRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.PeerlessBeautyLotteryRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.GoddessMissionRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.CommonWishScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.DeepFishingTotalCoinRank.getValue() == conditionType){
            return true;
        } else if (eGamePlayerEventType.ChannelPastureMaxScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.EnterNameAreaFightRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.LangYaMemorialCrossRank.getValue() == conditionType){
            return true;
        } else if (eGamePlayerEventType.LangYaUnionScoreRank.getValue() == conditionType){
            return true;
        } else if (eGamePlayerEventType.LangYaUserBuildingCoinRank.getValue() == conditionType){
            return true;
        } else if (eGamePlayerEventType.SilkRoadUserScoreRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.FlowerStudyScoreLocalRankCondition.getValue() == conditionType || eGamePlayerEventType.FlowerStudyScoreProvinceRankCondition.getValue() == conditionType || eGamePlayerEventType.FlowerStudyScorePalaceRankCondition.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.WanYaoUserPowerRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.QixiUserRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.GuaGiftsGuaRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.GuaGiftsNobleRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.GoldAutumnScoreCrossRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.DigGoldScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.EveFeastUserRank.getValue() == conditionType){
            return true;
        } else if (eGamePlayerEventType.DaoMuPvePersonRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.DaoMuPvpPersonRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.WitchDrawScoreRank.getValue() == conditionType){
            return true;
        } else if (eGamePlayerEventType.WaShePkUserFightRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.WaShePkGroupFightRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.SteleSoulRoundRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.MusicRoomScoreRank.getValue() == conditionType || eGamePlayerEventType.ServerMusicRoomScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.JiuZhouEliteScoreRoundRank.getValue() == conditionType || eGamePlayerEventType.JiuZhouEliteOutRoundRank.getValue() == conditionType
                || eGamePlayerEventType.JiuZhouMasterScoreRoundRank.getValue() == conditionType || eGamePlayerEventType.JiuZhouMasterOutRoundRank.getValue() == conditionType
                || eGamePlayerEventType.JiuZhouKingScoreRoundRank.getValue() == conditionType || eGamePlayerEventType.JiuZhouKingOutRoundRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.SnowGardenScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.SnowGardenSecondScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.RuiShouScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.ZhenHuanFirstProcessRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.ZhenHuanSecondProcessRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.ZhenHuanThirdProcessRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.BiaoJuExpRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.BiaoJuUnionExpRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.SpringDrawScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.SuiTangUserZhanGongRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.SuiTangUnionScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.FoxCardTreeScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.FoxCardMaxOnceDamageRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.HongXianUserRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.SummerGamesEntryScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.HarpsScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.SonHaiUserRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.SonHaiTeamRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.HsIslandUserRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.HsIslandUnionRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.TurtleUserRank.getValue() == conditionType) {
            return true;
        }  else if (eGamePlayerEventType.HorseRunUnionRacingScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.HorseRunPersonalGradeRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.HotpotJumpScoreRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.GashaponUserRank.getValue() == conditionType) {
            return true;
        } else if (eGamePlayerEventType.ApprenticeScoreRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.XingYouShanShuiUserSliverRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.XingYouShanShuiTeamSliverRank.getValue() == conditionType) {
            return true;
        }else if (eGamePlayerEventType.ChefDuel1StageScoreRank.getValue() == conditionType){
            return true;
        }else if (eGamePlayerEventType.ChefDuelPhase1UnlimitedRank.getValue() == conditionType){
            return true;
        } else if (eGamePlayerEventType.YQHotelPersonalScoreRank.getValue() == conditionType) {
            return true;
        }
        return false;
    }

    public static boolean isUserRankType(int conditionType) {
        if (eGamePlayerEventType.DaFuWengScoreRank.getValue() == conditionType) {
            return true;
        }
        if (eGamePlayerEventType.DaFuWengDamageRank.getValue() == conditionType) {
            return true;
        }
        if (eGamePlayerEventType.BowArtActivityScoreRank.getValue() == conditionType) {
            return true;
        }
        if (eGamePlayerEventType.BowArtActivityScoreCrossRank.getValue() == conditionType) {
            return true;
        }
        if(eGamePlayerEventType.DragonBoatRaceActivityScoreRank.getValue() == conditionType){
            return true;
        }
        if(eGamePlayerEventType.DragonBoatRaceActivityScoreCrossRank.getValue() == conditionType){
            return true;
        }
        if (eGamePlayerEventType.OperaMaskSumScoreRank.getValue() == conditionType) {
            return true;
        }
        if (eGamePlayerEventType.TombUserRank.getValue() ==conditionType){
            return true;
        }
        if (eGamePlayerEventType.DeepFishingTotalCoinRank.getValue() == conditionType){
            return true;
        }
        return false;
    }

    //todo-bug newRank的排行榜数据会把所有的condition都推上去，导致商会的也在个人里面了
    public static boolean bugNewRankUnionConditionCheck(int conditionType){
        if (eGamePlayerEventType.TwinsUnionScoreRank.getValue() == conditionType) {
            return true;
        }
        return false;
    }

    public static boolean isUnionRankType(int conditionType) {
        if (eGamePlayerEventType.DaFuWengUnionScoreRank.getValue() == conditionType) {
            return true;
        }
        if (eGamePlayerEventType.DaFuWengUnionDamageRank.getValue() == conditionType) {
            return true;
        }
        if (eGamePlayerEventType.BowArtActivityUnionScoreRank.getValue() == conditionType){
            return true;
        }
        if (eGamePlayerEventType.BowArtActivityUnionScoreCrossRank.getValue() == conditionType){
            return true;
        }
        if (eGamePlayerEventType.GhostUnionScoreRank.getValue() == conditionType) {
            return true;
        }
        if (eGamePlayerEventType.HangHaiUnionMoneyRank.getValue() == conditionType) {
            return true;
        }
        if (eGamePlayerEventType.DragonBoatRaceActivityUnionScoreRank.getValue() == conditionType) {
            return true;
        }
        if (eGamePlayerEventType.DragonBoatRaceActivityUnionScoreCrossRank.getValue() == conditionType) {
            return true;
        }
        if (eGamePlayerEventType.SeacraftPirateRiotUnionScoreRank.getValue() == conditionType) {
            return true;
        }
        if (eGamePlayerEventType.TombUnionRank.getValue() ==conditionType){
            return true;
        }
        if (eGamePlayerEventType.RankUnionWarUnionScoreRank.getValue() == conditionType) {
            return true;
        }
        if (eGamePlayerEventType.TwinsUnionScoreRank.getValue() == conditionType) {
            return true;
        }
        if (eGamePlayerEventType.PeakStrongHoldUnionIntegralRank.getValue() == conditionType) {
            return true;
        }
        if (eGamePlayerEventType.SteleSoulRoundRank.getValue() == conditionType){
            return true;
        }
        return false;
    }

    /**
     * 获取活动排行榜的排序比较器
     */
    public static Comparator getUserRankSorter(int activityType, int conditionType, boolean crossServer){
        if((activityType == eActivityType.GourdChildActivity.getValue() && (conditionType == eGamePlayerEventType.GourdChildPassProgressRank.getValue() || conditionType == eGamePlayerEventType.GourdChildPassProgressCrossRank.getValue()))
            || (activityType == eActivityType.DouLuoDaLuActivity.getValue() && (conditionType == eGamePlayerEventType.DouLuoDaLuPhaseOneUserScoreCrossRank.getValue() || conditionType == eGamePlayerEventType.DouLuoDaLuPhaseTwoUserScoreCrossRank.getValue()))
            || (activityType == eActivityType.ShuiHuYeZiCardActivity.getValue() && conditionType == eGamePlayerEventType.ShuiHuYeZiCardTotalCardLevelRank.getValue())
            || (activityType == eActivityType.ClimbTower.getValue() && conditionType == eGamePlayerEventType.ClimbTowerCellNumCrossRank.getValue())
            || (activityType == eActivityType.Twins.getValue() && conditionType == eGamePlayerEventType.TwinsPassDamageRank.getValue())
            || (activityType == eActivityType.Cat.getValue() && conditionType == eGamePlayerEventType.CatActivityPassRank.getValue())
            || (activityType == eActivityType.WorldCup.getValue() && conditionType == eGamePlayerEventType.WorldCupScoreRank.getValue())
            || (activityType == eActivityType.CarpTripActivity.getValue() && conditionType == eGamePlayerEventType.CarpTripCellNumCrossRank.getValue())
            || (activityType == eActivityType.XiuXian.getValue() && conditionType == eGamePlayerEventType.XiuXianXianLiRank.getValue())
            || (activityType == eActivityType.Feast.getValue() && conditionType == eGamePlayerEventType.FeastXianLiRank.getValue())
            || (activityType == eActivityType.GoddessActivity.getValue() && conditionType == eGamePlayerEventType.GoddessMissionRank.getValue())
            || (activityType == eActivityType.DaoMu.getValue() && conditionType == eGamePlayerEventType.DaoMuPvePersonRank.getValue())
            || (activityType == eActivityType.SteleSoul.getValue() && conditionType == eGamePlayerEventType.SteleSoulRoundRank.getValue())
            || (activityType == eActivityType.SnowGarden.getValue() && (conditionType == eGamePlayerEventType.SnowGardenSecondScoreRank.getValue()||conditionType == eGamePlayerEventType.SnowGardenScoreRank.getValue()))
            || (activityType == eActivityType.ZhenHuan.getValue() && conditionType == eGamePlayerEventType.ZhenHuanSecondProcessRank.getValue())
            || (activityType == eActivityType.Harps.getValue() && conditionType == eGamePlayerEventType.HarpsScoreRank.getValue())
            || (activityType == eActivityType.ChefDuel.getValue() && conditionType == eGamePlayerEventType.ChefDuel1StageScoreRank.getValue())
            || (activityType == eActivityType.ChefDuel.getValue() && conditionType == eGamePlayerEventType.ChefDuelPhase1UnlimitedRank.getValue())
        ){
            if(crossServer){
                return new CrossUserRankSortWithParam();
            }
            return new UserRankSortWithParam();
        }
        if (conditionType == eGamePlayerEventType.SeacraftPirateRiotScoreRank.getValue()) {
            return crossServer ? new CrossSeacraftPirateRiotChapterRankSort() : new SeacraftPirateRiotChapterRankSort();
        }
        if (conditionType == eGamePlayerEventType.PastureMaxScoreRank.getValue()) {
            return crossServer? new CrossPastureMaxScoreRankSort() : new PastureMaxScoreRankSort();
        }
        if (conditionType == eGamePlayerEventType.FellingTreesLevelRank.getValue()) {
            return crossServer ? new CrossFellingTreesLevelRankSort() : new FellingTreesLevelRankSort();
        }
        //param越短越好的排行
        if (activityType == eActivityType.FlowerStudy.getValue()
            && (conditionType == eGamePlayerEventType.FlowerStudyScorePalaceRankCondition.getValue()
                || conditionType == eGamePlayerEventType.FlowerStudyScoreLocalRankCondition.getValue()
                || conditionType == eGamePlayerEventType.FlowerStudyScoreProvinceRankCondition.getValue()
            )
        ) {
            return crossServer ? new CrossUserRankSortWithReverseParam() : new UserRankSortWithReverseParam();
        }
        if (activityType == eActivityType.DaoMu.getValue() && conditionType == eGamePlayerEventType.DaoMuPvpPersonRank.getValue()) {
            return crossServer ? new CrossDaoMuPvpPersonRankSort() : new DaoMuPvpPersonRankSort();
        }

        if(activityType == eActivityType.HotpotJump.getValue() && conditionType == eGamePlayerEventType.HotpotJumpScoreRank.getValue()) {
            return crossServer ? new CrossUserRankSortWithReverseParam() : new UserRankSortWithReverseParam();
        }
        return null;
    }

    public static Comparator getUnionRankSorter(int activityType, int conditionType, boolean crossServer){
        if((activityType == eActivityType.RankUnionWar.getValue() && conditionType == eGamePlayerEventType.RankUnionWarUnionScoreRank.getValue())){
            return new CrossUnionRankSortWithEarnSpeed();
        }
        if((activityType == eActivityType.PeakStrongHold.getValue() && conditionType == eGamePlayerEventType.PeakStrongHoldUnionIntegralRank.getValue())){
            return new CrossUnionRankSortWithParamValue();
        }
        return null;
    }

    /**
     * 是否跨地区活动
     * （瓦舍赛季需要导活动表，也在这里面）
     */
    public static boolean isCrossChannelActivityType(int activityType) {
        // 跨地区活动才加，不是的别加，会炸
        if (activityType == eActivityType.ChannelRankActivity.getValue()) {
            return true;
        }
        if (activityType == eActivityType.WasheActivity.getValue()) {
            return true;
        }
        if (activityType == eActivityType.CrossPasture.getValue()){
            return true;
        }
        if (activityType == eActivityType.ChannelTonBingActivity.getValue()){
            return true;
        }
        if (activityType == eActivityType.AreaWashePkActivity.getValue()){
            return true;
        }
        if (activityType == eActivityType.ChannelMusicRoomRank.getValue()){
            return true;
        }

        return false;
    }

    private static ActivityConfig getActivityConfig(Map<String, ActivityConfig> activityConfigMap, eActivityConfigType activityConfigType){
        ActivityConfig activityConfig;
        if(!activityConfigMap.containsKey(activityConfigType.getName())){
            activityConfig = new ActivityConfig();
            activityConfig.setParam(activityConfigType.getName());
            activityConfig.setValue(activityConfigType.getDefaultValue());
        }else {
            activityConfig = activityConfigMap.get(activityConfigType.getName());
        }
        return activityConfig;
    }

    public static String getActivityConfigValue(Map<String, ActivityConfig> activityConfigMap, eActivityConfigType activityConfigType){
        ActivityConfig activityConfig = getActivityConfig(activityConfigMap, activityConfigType);
        return activityConfig.getValue();
    }

    public static int getActivityConfigIntValue(Map<String, ActivityConfig> activityConfigMap, eActivityConfigType activityConfigType){
        ActivityConfig activityConfig = getActivityConfig(activityConfigMap, activityConfigType);
        return activityConfig.getIntValue();
    }

    public static long getActivityConfigLongValue(Map<String, ActivityConfig> activityConfigMap, eActivityConfigType activityConfigType) {
        ActivityConfig activityConfig = getActivityConfig(activityConfigMap, activityConfigType);
        return activityConfig.getLongValue();
    }

    public static List<Integer> getActivityConfigIntListValue(Map<String, ActivityConfig> activityConfigMap, eActivityConfigType activityConfigType, String separator) {
        ActivityConfig activityConfig = getActivityConfig(activityConfigMap, activityConfigType);
        return activityConfig.getIntListValue(separator);
    }

    /**
     * 获取活动开始时间到今天的天数 从1开始
     * @param activityInfo
     * @return
     */
    public static int getWhichDayAfterBeginTime(ActivityInfo activityInfo) {
        long beginTime = activityInfo.getBeginTime();
        long zeroTimeSecond = DateHelper.getZeroTimeStamp(beginTime * DateHelper.SECOND_MILLIONS);
        long todayZeroTime = DateHelper.getTodayZeroTimeStamp();
        if (todayZeroTime < zeroTimeSecond) {
            return 0;
        }
        int whichDay = (int) ((todayZeroTime - zeroTimeSecond) / DateHelper.DAY_MILLIONS) + 1;
        return whichDay;
    }

    /**
     *
     * @param activityInfo
     * @param compareTime 秒
     * @return
     */
    public static int getWhichDayAfterBeginTime(ActivityInfo activityInfo, long compareTime) {
        long beginTime = activityInfo.getBeginTime();
        long zeroTimeSecond = DateHelper.getZeroTimeStamp(beginTime * DateHelper.SECOND_MILLIONS);
        long todayZeroTime = DateHelper.getZeroTimeStamp(compareTime * DateHelper.SECOND_MILLIONS);
        if (todayZeroTime < zeroTimeSecond) {
            return 0;
        }
        int whichDay = (int) ((todayZeroTime - zeroTimeSecond) / DateHelper.DAY_MILLIONS) + 1;
        return whichDay;
    }

    /**
     * 获取活动持续时长
     *
     * @param activityInfo activityInfo
     * @return 活动持续时长
     */
    public static int getActivityDuration(ActivityInfo activityInfo) {
        long beginTime = activityInfo.getBeginTime();
        long zeroTimeSecond1 = DateHelper.getZeroTimeStamp(beginTime * DateHelper.SECOND_MILLIONS);
        long endTime = activityInfo.getEndTime();
        long zeroTimeSecond2 = DateHelper.getZeroTimeStamp(endTime * DateHelper.SECOND_MILLIONS);
        if (zeroTimeSecond2 < zeroTimeSecond1) {
            return 0;
        }
        return (int) ((zeroTimeSecond2 - zeroTimeSecond1) / DateHelper.DAY_MILLIONS) + 1;
    }
}
